from osgeo import ogr
# 列出ogr所有的驱动数据类型名称
def ogr_driver_list():
    cnt = ogr.GetDriverCount() ##获取驱动类型个数
    print(cnt) #打印驱动类型个数
    driverNameList=[] #定义存放驱动名称的数组
    for i in range(cnt):
        driver = ogr.GetDriver(i)#遍历所有驱动
        driverName = driver.GetName() #获取驱动名称
        if not driverName in driverNameList:
            driverNameList.append(driverName)
        if(i%5==0): #为方便查看每5个打印一组
            print(driverNameList)
            driverNameList=[] #打印完清空

def isOgrDriver(driverName):
    drv = ogr.GetDriverByName( driverName )
    if drv is None:
        print("%s driver not available.\n" % driverName)
    else:
        print("%s driver IS available.\n" % driverName)

if __name__ == '__main__':
    ## Shapefile available?
    driverName = "ESRI Shapefile"
    isOgrDriver(driverName)





